package com.jxc.service.admin.impl;

import com.jxc.dao.admin.OrderInDao;
import com.jxc.entity.admin.OrderIn;
import com.jxc.entity.admin.OrderInDetail;
import com.jxc.service.admin.OrderInService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description:
 */
@Service
public class OrderInServiceImpl implements OrderInService {

    @Autowired
    private OrderInDao orderinDao;

    @Override
    public int add(OrderIn orderin) {
        int rst = orderinDao.add(orderin);
        if(rst > 0){
            //表示进货单添加成功,接下来添加进货单子项
            for(OrderInDetail orderInDetail : orderin.getOrderInDetailList()){
                orderInDetail.setOrderInId(orderin.getId());
                orderinDao.addDetail(orderInDetail);
            }
        }
        return rst;
    }

    @Override
    public Integer getTotal(Map map) {
        return orderinDao.getTotal(map);
    }

    @Override
    public List<OrderIn> getList(Map map) {
        return orderinDao.findList(map);
    }

    @Override
    public int deleteByIds(String ids) {
        return orderinDao.delete(ids);
    }

    @Override
    public int edit(OrderIn orderin) {
        return orderinDao.edit(orderin);
    }

    @Override
    public OrderIn getOrderInById(String id) {
        return orderinDao.getOrderInById(id);
    }
}
